import get from '@dfeidao/atom-web/local/get';
import remove from '@dfeidao/atom-web/local/remove';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';
interface Aa {
	role_no: string;
}
export default async function a006(fd: IFeidaoAiBrowserComponent) {

	const productid = get(fd, 'productid');
	//  删除
	const role = get(fd, 'role') as Aa;
	const role_no = role.role_no;
	const pk_val = get(fd, 'pk_val');
	const _id = get(fd, 'role_allot_id');
	if (!pk_val) {
		error('请选择要删除的数据');
		return;
	}
	if (!role_no) {
		error('角色编码为空');
		return;
	}
	remove(fd, 'pk_val');
	remove(fd, 'role_allot_id');
	remove(fd, 'ff');
	show_loading();
	const res = await nodejs<{ length: number }>('roler/service/pub_role_allot_del', { _id, role_no, pk_val, productid });
	hide_loading();
	if (res === 'success') {
		fire('zj-000011', 'ec-005', { role_no, num: 1 });
		success('删除成功');
	} else {
		error('删除失败');
	}
}
